package com.taiyuan.tongcheng.widget;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;

import com.taiyuan.tongcheng.ui.CodeLoginActivity;
import com.taiyuan.tongcheng.ui.RegActivity;
import com.tytc56.user.R;

/**
 * 
 * @Description 订单类型选择
 * @author wzq
 * @date 2015-7-30 上午11:45:51
 * @update (date)
 * @version V1.0
 */
public class OrderStylePopupWindow extends PopupWindow {
	private View rootView; // 总的布局

	// 2个布局
	private RelativeLayout cagroLayout;
	private RelativeLayout movingLayout;

	// 2个图片
	private ImageView movingSel;
	private ImageView carGoSel;

	// 2个点击事件
	private View.OnClickListener movingClick;
	private View.OnClickListener carGoClick;

	// 上下文
	private Context context;

	public OrderStylePopupWindow(Context context,
			View.OnClickListener movingClick, View.OnClickListener carGoClick) {
		super(context);
		this.context = context;
		this.setWidth(LayoutParams.FILL_PARENT);
		this.setHeight(LayoutParams.FILL_PARENT);
		this.setBackgroundDrawable(new BitmapDrawable());// 这样设置才能点击屏幕外dismiss窗口
		this.setOutsideTouchable(true);
		this.setAnimationStyle(R.style.order_anim_style);
		LayoutInflater mLayoutInflater = LayoutInflater.from(context);
		rootView = mLayoutInflater
				.inflate(R.layout.layout_pw_order_style, null);
		cagroLayout = (RelativeLayout) rootView
				.findViewById(R.id.rl_order_cargo_sel);
		movingLayout = (RelativeLayout) rootView
				.findViewById(R.id.rl_order_moving_sel);
		movingSel = (ImageView) rootView.findViewById(R.id.img_move_select);
		carGoSel = (ImageView) rootView.findViewById(R.id.img_cargo_select);
		cagroLayout.setOnClickListener(carGoClick);
		movingLayout.setOnClickListener(movingClick);
		// 绑定事件
		setContentView(rootView);
	}

	/**
	 * 
	 * @Description: TODO
	 * @param type
	 *            1 搬家订单 2
	 * @return void
	 * @throws
	 * @autour Administrator
	 * @date 2015-8-30 上午12:52:42
	 * @update (date)
	 */
	public void setImgOrderSelect(int type) {
		switch (type) {
		case 1:
			movingSel.setImageResource(R.drawable.icon_ok_select);
			carGoSel.setImageResource(R.drawable.icon_ok_default);
			break;
		case 2:
			movingSel.setImageResource(R.drawable.icon_ok_default);
			carGoSel.setImageResource(R.drawable.icon_ok_select);
			break;
		default:
			break;
		}
	}

}
